package com.itheima.d4_jdk8_time;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class Test6_DateTimeFormatter {
    public static void main(String[] args)
    {
        // 1. 创建一个格式化对象
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        // 2. 格式化
        System.out.println(LocalDateTime.now());
        String s = dtf.format(LocalDateTime.now());
        System.out.println(s);


        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        System.out.println(now.format(dtf));
        System.out.println(dtf.format(now));

//        String s1 = "2020年06月06日 12:12:12";
//
//
//
//        System.out.println(ldt1);

        String s1 = "2020-06-06 12:12:12";
        LocalDateTime ldt1 = LocalDateTime.parse(s1, dtf);
        System.out.println(ldt1);

    }
}
